﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
    <script type="text/javascript" src="../../Content/highlighter/scripts/shCore.js"></script>
    <script type="text/javascript" src="../../Content/highlighter/scripts/shBrushJScript.js"></script>
    <script type="text/javascript" src="../../Content/highlighter/scripts/shBrushCSharp.js"></script>
    <script type="text/javascript" src="../../Content/highlighter/scripts/shBrushXml.js"></script>
    <link type="text/css" rel="stylesheet" href="../../Content/highlighter/styles/shCore.css" />
    <link type="text/css" rel="stylesheet" href="../../Content/highlighter/styles/shCoreEclipse.css" />
    <script type="text/javascript">SyntaxHighlighter.all();</script>
</head>
<body>
    <style>
        table {
            border-top: 1px solid black;
            border-left: 1px solid black;
        }

        td {
            border-right: 1px solid black;
            border-bottom: 1px solid black;
        }
    </style>
    <h3>参数验证</h3>
    <b>string验证</b><br/>
    1.命名空间引入 NFinal.Validation;<br />
    2.调用AsValidObject();<br />
    3.调用验证方法<br />
    <pre class="brush:csharp;">
        public class IndexController : BaseController
        {
            public void Index()
            {
                //单验证
                if(this.parameters["ShuLiang"].AsValidObject().IsNumber().validResult)
                {
                    this.Write("参数ShuLiang为数字！");
                }
                //多验证，使用+号
                if(this.parameters["ShuLiang"].Min(10).validResult
                +this.parameters["ShuLiang"].Max(40).validResult
                )
                {
                    this.Write("参数ShuLiang大于10，小于40！");
                }
            }
        }
    </pre>
    <table>
        <thead>
            <tr>
                <td>
                    函数
                </td>
                <td>
                    说明
                </td>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>Required</td>
                <td>参数不能为null</td>
            </tr>
            <tr>
                <td>IsNumber</td>
                <td>必须为数字</td>
            </tr>
            <tr>
                <td>IsEmail</td>
                <td>必须为邮箱</td>
            </tr>
            <tr>
                <td>IsUrl</td>
                <td>必须为Url</td>
            </tr>
            <tr>
                <td>IsDomain</td>
                <td>必须为域名</td>
            </tr>
            <tr>
                <td>IsMobile</td>
                <td>必须为手机号</td>
            </tr>
            <tr>
                <td>IsTelephone</td>
                <td>必须为电话</td>
            </tr>
            <tr>
                <td>IsIDCard</td>
                <td>必须为身份证号</td>
            </tr>
            <tr>
                <td>IsChinese</td>
                <td>必须为中文</td>
            </tr>
            <tr>
                <td>IsQQ</td>
                <td>必须为QQ号</td>
            </tr>
            <tr>
                <td>IsPostCode</td>
                <td>必须为邮政编码</td>
            </tr>
            <tr>
                <td>IsIp</td>
                <td>必须为IP地址</td>
            </tr>
            <tr>
                <td>Range</td>
                <td>数字范围</td>
            </tr>
            <tr>
                <td>Max</td>
                <td>最大值限制</td>
            </tr>
            <tr>
                <td>Min</td>
                <td>最小值限制</td>
            </tr>
            <tr>
                <td>Regex</td>
                <td>正则验证</td>
            </tr>
            <tr>
                <td>Length</td>
                <td>长度限制</td>
            </tr>
        </tbody>
    </table>
</body>
</html>